package com.atguigu.lease.web.admin.custom.converter;

import com.atguigu.lease.model.enums.ItemType;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

@Deprecated
@Component
public class StringToItemTypeConverter implements Converter<String, ItemType> {

    @Override
    public ItemType convert(String source) {

        ItemType itemType = null;

        ItemType[] values = ItemType.values();
        for (ItemType value : values) {
            if (value.getCode().toString().equals(source)) {
                itemType = value;
                break;
            }
        }

        return itemType;
    }
}
